<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>主页</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="${ctx}/static/admin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="${ctx}/static/admin/layui/css/admin.css" media="all">
</head>
<body>
<div class="layui-fluid">
  <div class="layui-row layui-col-space15">
      <div class="layui-col-md8">
        <div class="layui-row layui-col-space15">
<!--
            <div class="layui-col-md6">
            <div class="layui-card">
              <div class="layui-card-header">公司基本信息</div>
              <div class="layui-card-body">
                <div class="layui-carousel layadmin-carousel layadmin-backlog">
                   <ul class="layui-row layui-col-space10">
                     <li class="layui-col-xs6">
                       <a href="javascript:;" class="layadmin-backlog-body">
                         <h3>产品类型</h3>
                         <p><cite id="productnum"></cite></p>
                       </a>
                     </li>
                     <li class="layui-col-xs6">
                       <a href="javascript:;" class="layadmin-backlog-body">
                         <h3>成功案例</h3>
                         <p><cite id="casenum"></cite></p>
                       </a>
                     </li>
                     <li class="layui-col-xs6">
                       <a href="javascript:;" class="layadmin-backlog-body">
                         <h3>合作伙伴</h3>
                         <p><cite id="partnernum"></cite></p>
                       </a>
                     </li>
                     <li class="layui-col-xs6">
                       <a href="javascript:;" class="layadmin-backlog-body">
                         <h3>新闻量</h3>
                         <p><cite id="newsnum"></cite></p>
                       </a>
                     </li>
                   </ul>
                </div>
              </div>
            </div>
          </div>
          -->
          <div class="layui-col-md12">
            <div class="layui-card">
              <div class="layui-card-header">快捷方式</div>
              <div class="layui-card-body">
                <div class="layui-carousel layadmin-carousel layadmin-shortcut">
                  <ul class="layui-row layui-col-space10">
                      <li class="layui-col-xs3">
                        <a href="javascript:;" onclick="openWNL()">
                          <i class="layui-icon layui-icon-date"></i>
                          <cite>万年历</cite>
                        </a>
                      </li>
                      <li class="layui-col-xs3">
                        <a href="javascript:;" onclick="openTQ()">
                          <i class="layui-icon layui-icon-upload"></i>
                          <cite>天气</cite>
                        </a>
                      </li>
                      <li class="layui-col-xs3">
                        <a href="javascript:;" onclick="">
                          <i class="layui-icon layui-icon-fonts-html"></i>
                          <cite>产品录入</cite>
                        </a>
                      </li>
                      <li class="layui-col-xs3">
                        <a href="javascript:;" onclick="">
                          <i class="layui-icon layui-icon-fonts-code"></i>
                          <cite>案例录入</cite>
                        </a>
                      </li>
                      <li class="layui-col-xs3">
                        <a href="javascript:;" onclick="">
                          <i class="layui-icon layui-icon-chart"></i>
                          <cite>合作伙伴录入</cite>
                        </a>
                      </li>
                      <li class="layui-col-xs3">
                        <a href="javascript:;" onclick="">
                          <i class="layui-icon layui-icon-form"></i>
                          <cite>新闻录入</cite>
                        </a>
                      </li>
                      <li class="layui-col-xs3">
                        <a href="javascript:;" onclick="">
                          <i class="layui-icon layui-icon-tree"></i>
                          <cite>公司信息</cite>
                        </a>
                      </li>
                      <li class="layui-col-xs3">
                        <a href="javascript:;" onclick="">
                          <i class="layui-icon layui-icon-survey"></i>
                          <cite>数据字典</cite>
                        </a>
                      </li>
                    </ul>
                </div>
              </div>
            </div>
          </div>
          <!--
            <div class="layui-col-md12">
            <div class="layui-card">
              <div class="layui-card-header">产品案例数量图</div>
              <div class="layui-card-body">
                <div class="layui-carousel layadmin-carousel layadmin-dataview" data-anim="fade">
                  <div id="casesdiv" style="height: 330px;"></div>
                </div>
              </div>
            </div>
            <div class="layui-card">
              <div class="layui-tab layui-tab-brief layadmin-latestData">
                <ul class="layui-tab-title">
                  <li class="layui-this">产品案例数量排行</li>
                  <li>新闻点击数量排行</li>
                </ul>
                <div class="layui-tab-content">
                  <div class="layui-tab-item layui-show">
                    <table id="casestable"></table>
                  </div>
                  <div class="layui-tab-item">
                    <table id="newstable"></table>
                  </div>
                </div>
              </div>
            </div>
          </div>
        -->
        </div>
      </div>
      
      <div class="layui-col-md4">
        <div class="layui-card">
          <div class="layui-card-header">系统信息</div>
          <div class="layui-card-body layui-text">
            <table class="layui-table" lay-size="sm" lay-even="true" style="height: 175px">
              <colgroup>
                <col width="100">
                <col>
              </colgroup>
              <tbody>
                <tr>
                  <td>系统名称</td>
                  <td>郑州创梦计算机科技有限公司官方网站</td>
                </tr>
                <tr>
                  <td>当前版本</td>
                  <td>v1.0</td>
                </tr>
                <tr>
                  <td>所用技术</td>
                  <td>Jfinal（后台框架）+Beetl（模版引擎）+Layui（前台框架）+MySql（数据库）</td>
                </tr>
                <tr id="svntrid" style="height: 42px">
                  <td>SVN地址</td>
                  <td>
                    <div class="layui-row">
					    <div class="layui-col-xs10">
					       <span id="svnurlid" style="color: green">https://140.143.241.93:1443/svn/myproject/cmkjweb</span>
					    </div>
					    <div class="layui-col-xs2">
		                    <a id="copyid" href="javascript:;" style="display: none;right: 0" class="layui-btn layui-btn-normal layui-btn-xs">复制</a>
					    </div>
					</div>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
        <!--
         <div class="layui-card">
           <div class="layui-card-header">合作伙伴案例数量图</div>
           <div class="layui-card-body layadmin-takerates">
             <div id="partnercases" style="height:337px;"></div>
           </div>
         </div>

         <div class="layui-card">
           <div class="layui-card-header">实时监控</div>
           <div class="layui-card-body layadmin-takerates">
             <div class="layui-progress" lay-filter="cpu" lay-showPercent="yes">
               <h3>CPU使用率</h3>
               <div id="cpuid" class="layui-progress-bar" lay-percent=""></div>
             </div>
             <div class="layui-progress" lay-filter="ram" lay-showPercent="yes">
               <h3>内存占用率</h3>
               <div id="ramid" class="layui-progress-bar layui-bg-red" lay-percent=""></div>
             </div>
           </div>
         </div>

         <div class="layui-card">
           <div class="layui-card-header">
             <span>项目管理制度</span>
             <i class="layui-icon layui-icon-tips" lay-tips="要支持的噢" lay-offset="5"></i>
           </div>
           <div class="layui-card-body layui-text layadmin-text">
             <p>添加工作量计划时，请按照个人实际情况录入</p>
             <p>如有无法解决问题，要及时联系项目经理</p>
             <p>子曰：学而时习之不亦说乎！三人行必有我师焉！</p>
             <p>—— 创梦科技（<a href="http://www.zzcmkj.net/" target="_blank">zzcmkj.net</a>）</p>
           </div>
         </div>
       </div>
       -->
    </div>
</div>
  <script src="${ctx}/static/admin/layui/layui.js"></script>
  <script src="${ctx}/static/echarts/echarts.min.js"></script>
  <script>
  function fmoney(s, n) {
   n = n > 0 && n <= 20 ? n : 2;
   s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";
   var l = s.split(".")[0].split("").reverse(),
   r = s.split(".")[1];
   t = "";
   for (i = 0; i < l.length; i ++ ) {
      t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");
   }
   return t.split("").reverse().join("") + "." + r;
}
  var tableIns;
  var newstable;
  var $;
  var element;
  layui.config({
    base: '${ctx}/static/admin/js/' //静态资源所在路径
  }).extend({
    index: 'index' //主入口模块
  }).use(['jquery','table','layer', 'element','index'], function(){
    $ = layui.jquery;
    var table = layui.table;
    var layer = layui.layer;
    element = layui.element;
    
    $('#svntrid').hover(function() {
             // 鼠标移入时添加hover类
        $('#copyid').show();
    }, function() {
        // 鼠标移出时移出hover类
        $('#copyid').hide();
    });
    
    $('#copyid').click(function(){
        var copyvalue = $('#svnurlid').text();
        var oInput = document.createElement('input');
        oInput.value = copyvalue;
        document.body.appendChild(oInput);
        oInput.select(); // 选择对象
        document.execCommand("Copy"); // 执行浏览器复制命令
        oInput.className = 'oInput';
        oInput.style.display='none';
        layer.msg('复制成功！');
    });
    
    tableIns = table.render({
		elem: '#casestable',
		height:'343',
		size:'sm',
	    url: '${ctx}/sys_admin/main/getCasesList',
	    even: true,
	    cols: [[
		  {type: 'numbers'},
		  {field: 'name', title: '产品名称'},
		  {field: 'casenum', title: '成功案例数量', width:180}
	    ]]
	});
    
    newstable = table.render({
		elem: '#newstable',
		height:'343',
		size:'sm',
	    url: '${ctx}/sys_admin/main/getNewsList',
	    even: true,
	    cols: [[
		  {type: 'numbers'},
		  {field: 'title', title: '新闻标题'},
		  {field: 'img', title: '新闻图片', width:180, align:'center',
             templet: function(res){
			   if(res.img != '' && res.img != null  && res.img != undefined){
				   return '<div class="layer-photos-demo" style="cursor:pointer;">' +
                   '<img layer-pid=""  layer-src="' + res.img + '" src="' + res.img + '" height="25px">' +
                   '</div>';
			   }else{
			   	   return "";
			   }
			}
		  },
		  {field: 'clicknum', title: '新闻点技数量', width:180, align:'center'}
	    ]],
	    done:function(res, curr){
	      layer.photos({
              photos: '.layer-photos-demo',
              anim: 1
          });
	    }
	});
	
	//setInterval(getWindowsInfo, 60000);
    
    $.ajax({
		type: "POST",
		url: '${ctx}/sys_admin/main/getCompanyInfo',
		//async:false,
		success: function(data){
			$('#productnum').html(data.productnum);
			$('#casenum').html(data.casenum);
			$('#partnernum').html(data.partnernum);
			$('#newsnum').html(data.newsnum);
		}
	});
	
    var intervalIndex = setInterval(function() {
      if (echarts === undefined) {
          return;
      }
      // 如果eacharts加载完成，则清除循环
      clearInterval(intervalIndex);
      //echarts
      // 基于准备好的dom，初始化echarts实例
          
      var allcases;
      $.ajax({
		type: "POST",
		url: '${ctx}/sys_admin/main/getAllCases',
		async:false,
		success: function(data){
			allcases = data;
		}
	  });
	  
	  var pcases;
      $.ajax({
		type: "POST",
		url: '${ctx}/sys_admin/main/getPartnerCases',
		async:false,
		success: function(data){
			pcases = data;
		}
	  });
    var dom = document.getElementById("casesdiv");
	var cases = echarts.init(dom);
	var app = {};
	option = null;
	var posList = [
	    'left', 'right', 'top', 'bottom',
	    'inside',
	    'insideTop', 'insideLeft', 'insideRight', 'insideBottom',
	    'insideTopLeft', 'insideTopRight', 'insideBottomLeft', 'insideBottomRight'
	];
			
	app.configParameters = {
	    rotate: {
	        min: -90,
	        max: 90
	    },
	    align: {
	        options: {
	            left: 'left',
	            center: 'center',
	            right: 'right'
	        }
	    },
	    verticalAlign: {
	        options: {
	            top: 'top',
	            middle: 'middle',
	            bottom: 'bottom'
	        }
	    },
	    position: {
	        options: echarts.util.reduce(posList, function (map, pos) {
	            map[pos] = pos;
	            return map;
	        }, {})
	    },
	    distance: {
	        min: 0,
	        max: 100
	    }
	};
			
	app.config = {
	    rotate: 90,
	    align: 'left',
	    verticalAlign: 'middle',
	    position: 'insideBottom',
	    distance: 15,
	    onChange: function () {
	        var labelOption = {
	            normal: {
	                rotate: app.config.rotate,
	                align: app.config.align,
	                verticalAlign: app.config.verticalAlign,
	                position: app.config.position,
	                distance: app.config.distance
	            }
	        };
	        cases.setOption({
	            series: [{
	                label: labelOption
	            }, {
	                label: labelOption
	            }, {
	                label: labelOption
	            }, {
	                label: labelOption
	            }]
	        });
	    }
	};
			
			
	var labelOption = {
	    normal: {
	        show: true,
	        position: app.config.position,
	        distance: app.config.distance,
	        align: app.config.align,
	        verticalAlign: app.config.verticalAlign,
	        rotate: app.config.rotate,
	        formatter: '{c}  {name|{a}}',
	        fontSize: 16,
	        rich: {
	            name: {
	                textBorderColor: '#fff'
	            }
	        }
	    }
	};
	
	option = {
	    color: ['#003366','#e5323e'],
	    tooltip: {
	        trigger: 'axis',
	        axisPointer: {
	            type: 'shadow'
	        }
	    },
	    legend: {
	        data: allcases.y
	    },
	    toolbox: {
	        show: true,
	        orient: 'horizontal',
	        left: 'right',
	        top: 'top',
	        feature: {
	            mark: {show: true},
	            dataView: {show: true, readOnly: false},
	            magicType: {show: true, type: ['line', 'bar', 'stack', 'tiled']},
	            restore: {show: true},
	            saveAsImage: {show: true}
	        }
	    },
	    calculable: true,
	    xAxis: [
	        {
	            type: 'category',
	            axisLabel:{interval:0},
	            axisTick: {show: true},
	            splitLine: {show: true},
	            data: allcases.x
	        }
	    ],
	    yAxis: [
	        {
	            type: 'value'
	        }
	    ],
	    series:allcases.data
	};
	  if (option && typeof option === "object") {
		cases.setOption(option, true);
	  }
			
	  var partnercases = echarts.init(document.getElementById("partnercases"));
      var app1 = {};
      option1 = null;
      app1.title = '极坐标系下的堆叠柱状图';
     
      option1 = {
        title: {
          text: '',
          subtext: '当前所有案例',
          x: 'center'
        },
        tooltip: {
          trigger: 'item',
          formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
          orient: 'vertical',
          left: 'left',
          data: pcases.typeName
        },
        series: [{
          name: '案例数量',
          type: 'pie',
          radius: '55%',
          center: ['50%', '60%'],
          data: pcases.data,
          itemStyle: {
            emphasis: {
              shadowBlur: 10,
              shadowOffsetX: 0,
              shadowColor: 'rgba(0, 0, 0, 0.5)'
            }
          }
        }]
      };
      if (option1 && typeof option1 === "object") {
        partnercases.setOption(option1, true);
      }
      $(window).on('resize', function() {
        cases.resize();
        partnercases.resize();
      });
      
     }, 50);
  });
  
  function openProduct() {
	parent.layer.open({
		type: 2,
		title: '产品',
		area: ['95%', '95%'],
		fixed: false, //不固定
		maxmin: true,
		content: '${ctx}/sys_admin/products/fastForm',
		btn: ['提交','重置','取消'],
		yes: function(index, layero){
               var iframeWin = layero.find('iframe')[0];
               iframeWin.contentWindow.table = tableIns;
               layero.find('iframe').contents().find('#submit-btn').click();
	  	},
	  	btn2: function(index, layero){
	  		var iframeWin = layero.find('iframe')[0];
               iframeWin.contentWindow.table = tableIns;
               layero.find('iframe').contents().find('#reset-btn').click();
               return false;
	  	},
	  	btn3: function(index, layero){
  			var index = layer.getFrameIndex(window.name);
			layer.close(index);
	  	}
	});
  }
  
  function openCase() {
	parent.layer.open({
		type: 2,
		title: '案例',
		area: ['95%', '95%'],
		fixed: false, //不固定
		maxmin: true,
		content: '${ctx}/sys_admin/cases/fastForm',
		btn: ['提交','重置','取消'],
		yes: function(index, layero){
               var iframeWin = layero.find('iframe')[0];
               iframeWin.contentWindow.table = tableIns;
               layero.find('iframe').contents().find('#submit-btn').click();
	  	},
	  	btn2: function(index, layero){
	  		var iframeWin = layero.find('iframe')[0];
               iframeWin.contentWindow.table = tableIns;
               layero.find('iframe').contents().find('#reset-btn').click();
               return false;
	  	},
	  	btn3: function(index, layero){
  			var index = layer.getFrameIndex(window.name);
			layer.close(index);
	  	}
	});
  }
  
  function openPartner() {
	parent.layer.open({
		type: 2,
		title: '合作伙伴',
		area: ['95%', '95%'],
		fixed: false, //不固定
		maxmin: true,
		content: '${ctx}/sys_admin/partners/fastForm',
		btn: ['提交','重置','取消'],
		yes: function(index, layero){
               var iframeWin = layero.find('iframe')[0];
               iframeWin.contentWindow.table = tableIns;
               layero.find('iframe').contents().find('#submit-btn').click();
	  	},
	  	btn2: function(index, layero){
	  		var iframeWin = layero.find('iframe')[0];
               iframeWin.contentWindow.table = tableIns;
               layero.find('iframe').contents().find('#reset-btn').click();
               return false;
	  	},
	  	btn3: function(index, layero){
  			var index = layer.getFrameIndex(window.name);
			layer.close(index);
	  	}
	});
  }
  
  function openNews() {
	parent.layer.open({
		type: 2,
		title: '新闻',
		area: ['95%', '95%'],
		fixed: false, //不固定
		maxmin: true,
		content: '${ctx}/sys_admin/news/fastForm',
		btn: ['提交','重置','取消'],
		yes: function(index, layero){
               var iframeWin = layero.find('iframe')[0];
               iframeWin.contentWindow.table = tableIns;
               layero.find('iframe').contents().find('#submit-btn').click();
	  	},
	  	btn2: function(index, layero){
	  		var iframeWin = layero.find('iframe')[0];
               iframeWin.contentWindow.table = tableIns;
               layero.find('iframe').contents().find('#reset-btn').click();
               return false;
	  	},
	  	btn3: function(index, layero){
  			var index = layer.getFrameIndex(window.name);
			layer.close(index);
	  	}
	});
  }
  
  function openCompany() {
	parent.layer.open({
		type: 2,
		title: '公司信息',
		area: ['95%', '95%'],
		fixed: false, //不固定
		maxmin: true,
		content: '${ctx}/sys_admin/constants'
	});
  }
  
  function openDict() {
	parent.layer.open({
		type: 2,
		title: '数据字典',
		area: ['95%', '95%'],
		fixed: false, //不固定
		maxmin: true,
		content: '${ctx}/sys_admin/sys/dict'
	});
  }
  
  function openWNL() {
    parent.layer.open({
         type: 2,
         title: '万年历',
         area: ['80%', '90%'],
         fixed: false, //不固定
         maxmin: true,
         content: 'http://yun.rili.cn/wnl/index.html'
    });
  }
  
  function openTQ() {
    parent.layer.open({
         type: 2,
         title: '天气',
         area: ['80%', '90%'],
         fixed: false, //不固定
         maxmin: true,
         content: 'http://www.weather.com.cn/weather1d/101180101.shtml'
    });
  }
  
  function getWindowsInfo() {
    $.ajax({
		type: "POST",
		url: '${ctx}/sys_admin/main/getWindowsInfo',
		success: function(data){
		    element.progress('cpu', data.cpu);
		    element.progress('ram', data.ram);
		}
	});
  }
  </script>
</body>
</html>